/*
    Basic DLL File !
    @5mukx
*/

use std::ffi::CString;

use winapi::um::winuser::MessageBoxA;
use winapi::um::winuser::{MB_ICONEXCLAMATION, MB_OK};

fn msg_box_payload() {
    unsafe {
        let lp_text = CString::new("Hey, its me 5mukx !").unwrap();
        let lp_caption = CString::new("Wow !").unwrap();

        MessageBoxA(
            std::ptr::null_mut(),
            lp_text.as_ptr(),
            lp_caption.as_ptr(),
            MB_OK | MB_ICONEXCLAMATION,
        );
    }
}

// DLL Entrypoint ->
#[unsafe(no_mangle)]
pub extern "system" fn DllMain(_h_module: *mut u8, dw_reason: u32, _lp_reserved: *mut u8) -> i32 {
    use winapi::um::winnt::{
        DLL_PROCESS_ATTACH, DLL_PROCESS_DETACH, DLL_THREAD_ATTACH, DLL_THREAD_DETACH,
    };

    match dw_reason {
        DLL_PROCESS_ATTACH => {
            msg_box_payload();
        }
        DLL_PROCESS_DETACH => {}
        DLL_THREAD_ATTACH => {}
        DLL_THREAD_DETACH => {}
        _ => {}
    }
    1
}
